package com.zxl.common.utils;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;
import java.util.UUID;

/**
 * @author zxw
 * @date 2023/3/31
 */
public class OrderUtils {
    public static final String C_PREFIX = "C";

    /**
     * 生成订单
     *
     * @param prefix
     * @return
     */
    public static String generatorOrderCode(String prefix) {
        StringBuilder sb = new StringBuilder();
        if (StringUtils.isBlank(prefix)) {
            prefix = C_PREFIX;
        }
        sb.append(prefix);
        sb.append(IdUtil.fastUUID().replaceAll("-", "").substring(0, 5));
        sb.append(System.currentTimeMillis());
        return sb.toString();
    }


}

